package com.fxc.handler;

import com.fxc.api.EmployeeRemoteService;
import com.fxc.entity.Employee;
import com.fxc.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class FeignHumanResourceHandler {

    // 装配调用远程微服务接口，后面像调用本地接口一样直接使用
    @Autowired
    private EmployeeRemoteService employeeRemoteService;

    @RequestMapping("/feign/consumer/get/test/fallback")
    public ResultEntity<Employee> testFallBack(@RequestParam("signal") String signal){

        return employeeRemoteService.getEmpWithCircuitBreaker(signal);
    }

    @RequestMapping("/feign/consumer/get/emp")
    public Employee getEmployeeRemote(){
        return employeeRemoteService.getEmployeeRemote();
    }

    @RequestMapping("/provider/list/remote")
    public List<Employee> getListEmpListRemote(@RequestParam("keyword") String keyword){

        return employeeRemoteService.getListEmpListRemote(keyword);
    }
}
